package com.passionfruit.web.www;

import com.google.common.collect.Maps;
import com.passionfruit.module.entity.BlogArticle;
import com.passionfruit.module.entity.BlogArticleCate;
import com.passionfruit.module.service.IBlogArticleCateService;
import com.passionfruit.module.service.IBlogArticleService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

/**
 * Created by weirdor on 2017/11/8.
 */
@Controller
public class HomeController {
    @Autowired
    private IBlogArticleCateService blogArticleCateService;

    @Autowired
    private IBlogArticleService blogArticleService;

    @RequestMapping("/")
    public ModelAndView index() {
        return new ModelAndView("index.html");
    }

    /**
     * 信息
     */
    @RequestMapping("/infos/{id}")
    public ModelAndView info(@PathVariable("id") Integer id){
        BlogArticle blogArticle = blogArticleService.selectById(id);
        ModelAndView modelAndView=new ModelAndView();
        modelAndView.addObject("blogArticleCate",blogArticle);
        modelAndView.setViewName("/post.html");
        return modelAndView;
    }
}
